<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$ui = new UI();
include( "member/news.php" );
$tpl = new Template2();
$conf = new config();
$lotto_id = 0;
if (isset($_GET['lotto_id']))
{
    $lotto_id = intval($_GET['lotto_id']);
}
if ($lotto_id == 0)
{
    $rs = getdb("select id from lotto where open>='" . date("Y-m-d") . "' order by open");
    if ($rs->eof)
    {
        $ui->showErrorPage("<p>目前没有可以下注期数！</p>");
        exit();
    }
    $lotto_id = $rs->f['id'];
}
if ($curruser['enabled'] == 0 || $curruser['enabled'] == 2)
{
    $ui->showErrorPage("<p class=error>帐号已被暂停使用</p>");
    exit();
}
$rs = getdb("select * from lotto where id = " . $lotto_id);
if ($rs->eof)
{
    $ui->showErrorPage("<p>错误！</p>");
    exit();
}
$open = $rs->f['open'];
$round = $rs->f['round'];
$rs1 = getdb("select id from lotto where open > '{$open}' order by open");
$next_id = $rs1->f['id'];
$rs1 = getdb("select id from lotto where open < '{$open}' order by open desc");
$prev_id = $rs1->f['id'];
$pnStr = "";

$pnStr .= " [ 下注期数：<b>" . d3($round) . "</b>  开奖日：<b>" . $open . "</b> ]";

if (isset($_GET['cmd']) && $_GET['cmd'] == "stopnow0")
{
    $conf->set("linebet", date("Hi", systime() - 60));
    $conf->set("waitbet", date("Hi", systime() - 60));
    $conf->set("stopbet", date("Hi", systime() - 60));
}
$waitbet = $conf->get("waitbet");
$t2 = strtotime($open . " " . $waitbet);
$tpl->Set("timestap2", $t2 - systime());
$stopbet = $conf->get("stopbet");
$t1 = strtotime($open . " " . $stopbet);
$tpl->Set("timestap", $t1 - systime());
$tpl->Set("fp", $fp);
$tpl->Set("lotto_id", $lotto_id);
if (!isset($_SESSION['split']))
{
    $_SESSION['split'] = 1;
}
$split = $_SESSION['split'];
if (isset($_GET['split']))
{
    $split = intval($_GET['split']);
    $_SESSION['split'] = $split;
}
$tpl->set("split", $split);
if ($split == 1)
{
    $tpl->set("td0", "td3");
}
else
{
    $tpl->set("td0", "td0");
}
if (!isset($_SESSION['bets']))
{
    $_SESSION['bets'] = 0;
}
$bets = $_SESSION['bets'];
if (isset($_GET['bets']))
{
    $bets = intval($_GET['bets']);
    $_SESSION['bets'] = $bets;
}
$tpl->set("bets", $bets);
if (!isset($_SESSION['ratemod']))
{
    $_SESSION['ratemod'] = 0;
}
$ratemod = $_SESSION['ratemod'];
if (isset($_GET['ratemod']))
{
    $ratemod = intval($_GET['ratemod']);
    $_SESSION['ratemod'] = $ratemod;
}
$tpl->set("ratemod", $ratemod);
$percurl = preg_replace("/split=\\d?/", "", $_SERVER['REQUEST_URI']);
$list = "&nbsp;&nbsp;&nbsp;成数：<select onchange=\"location.replace('" . $percurl . "&split=' + this.value)\">";
$list .= "<option value=0";
if ($split == 0)
{
    $list .= " selected";
}
$list .= ">全部<option value=1";
if ($split == 1)
{
    $list .= " selected";
}
$list .= ">成数</select>";
$tpl->set("bypercent", $list);
$tpl->set("split_id", $split);
$tpl->set("phptime", systime());
$disk = 0;
if (isset($_GET['disk']) && $_GET['disk'] != "")
{
    switch ($_GET['disk'])
    {
        case "1" :
            $disk = 1;
            break;
        case "2" :
            $disk = 2;
            break;
        case "3" :
            $disk = 3;
            break;
        case "4" :
            $disk = 4;
            break;
    }
}
$diskurl = preg_replace("/disk=\\d?/", "", $_SERVER['REQUEST_URI']);
$disks = "&nbsp;&nbsp;&nbsp;盘类：<select name=disk onchange=\"location.replace('" . $diskurl . "&disk='+this.value)\">";
$disks .= "<option value=0" . ( $disk == 0 ? " selected" : "" ) . ">全部";
$disks .= "<option value=1" . ( $disk == 1 ? " selected" : "" ) . ">A 盘";
$disks .= "<option value=2" . ( $disk == 2 ? " selected" : "" ) . ">B 盘";
$disks .= "<option value=3" . ( $disk == 3 ? " selected" : "" ) . ">C 盘";
$disks .= "<option value=4" . ( $disk == 4 ? " selected" : "" ) . ">D 盘";
$disks .= "</select>";
$tpl->set("disks", $disks);
$tpl->set("disk_id", $disk);
$betsurl = preg_replace("/bets=\\d?/", "", $_SERVER['REQUEST_URI']);
$blist = "&nbsp;&nbsp;&nbsp;显示：<select name=bets onchange=\"location.replace('" . $betsurl . "&bets='+this.value)\">";
$blist .= "<option value=0" . ( $bets == 0 ? " selected" : "" ) . ">全部&#12288;";
$blist .= "<option value=1" . ( $bets == 1 ? " selected" : "" ) . ">特码Ａ";
$blist .= "<option value=2" . ( $bets == 2 ? " selected" : "" ) . ">特码Ｂ";
$blist .= "</select>";
$tpl->set("betmode", $blist);
$tpl->set("bets_id", $bets);
$rateurl = preg_replace("/ratemod=\\d?/", "", $_SERVER['REQUEST_URI']);
$rlist = "&nbsp;&nbsp;&nbsp;赔率：<select name=ratemod onchange=\"location.replace('" . $rateurl . "&ratemod='+this.value)\">";
$rlist .= "<option value=0" . ( $ratemod == 0 ? " selected" : "" ) . ">目前赔率";
$rlist .= "<option value=1" . ( $ratemod == 1 ? " selected" : "" ) . ">平均赔率";
$rlist .= "<option value=2" . ( $ratemod == 2 ? " selected" : "" ) . ">输赢赔率";
$rlist .= "</select>";
$tpl->set("mess", $rlist);
$tpl->set("rate_id", $ratemod);
include_once( "class_6h/class.menu.php" );
$fieldArr = array("lotto_id" => $lotto_id, "split_id" => $split, "disk_id" => $disk, "bypercent" => $list, "disks" => $disks, "pnStr" => $pnStr, "bets" => $bets);
$onlineMenu = new menu_6h(0, $fieldArr);
$selectid = getvar("select") == "" ? 0 : getvar("select");
$tpl->set("selectid", $selectid);
$menuList = $onlineMenu->getMenu($selectid);
$tpl->set("menuList", $menuList);
unset($onlineMenu);
?>